﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class UserControls_MainFigures : System.Web.UI.UserControl
{
  protected void Page_Load(object sender, EventArgs e)
  {
    string id = Request.Params["id"];
    StockAnalysis analysis = new StockAnalysis();
    DataTable dt = analysis.GetMainFiguresTable(id);

    gridviewYears.DataSource = ConvertMainFigures.ConvertYears(dt);
    gridviewYears.DataBind();

    gridviewIncomeStatement.DataSource = ConvertMainFigures.ConvertIncomeStatement(dt);
    gridviewIncomeStatement.DataBind();

    gridviewAssets.DataSource = ConvertMainFigures.ConvertAssets(dt);
    gridviewAssets.DataBind();

    gridviewLiabilities.DataSource = ConvertMainFigures.ConvertLiabilities(dt);
    gridviewLiabilities.DataBind();

    gridviewOtherInfo.DataSource = ConvertMainFigures.ConvertOtherInfo(dt);
    gridviewOtherInfo.DataBind();
  }

  protected void gridviewYears_RowDataBound(object sender, GridViewRowEventArgs e)
  {
    e.Row.Cells[0].Width = Unit.Percentage(35);
  }

  protected void gridviewIncomeStatement_RowDataBound(object sender, GridViewRowEventArgs e)
  {
    e.Row.Cells[0].Width = Unit.Percentage(35);
  }

  protected void gridviewAssets_RowDataBound(object sender, GridViewRowEventArgs e)
  {
    e.Row.Cells[0].Width = Unit.Percentage(35);
    if (e.Row.Cells[0].Text.Equals(Dictionary.Translate("total_assets")))
      e.Row.Font.Bold = true;
  }

  protected void gridviewLiabilities_RowDataBound(object sender, GridViewRowEventArgs e)
  {
    e.Row.Cells[0].Width = Unit.Percentage(35);
    if (e.Row.Cells[0].Text.Equals(Dictionary.Translate("total_liabilities")))
      e.Row.Font.Bold = true;
  }

  protected void gridviewOtherInfo_RowDataBound(object sender, GridViewRowEventArgs e)
  {
    e.Row.Cells[0].Width = Unit.Percentage(35);
  }

}